package com.eling.elcms.travel.model;

import com.eling.elcms.basedoc.model.CommunityData;
import com.eling.elcms.core.dao.annotation.CriteriaEnhancer;
import com.eling.elcms.core.dao.annotation.CriteriaEnhancers;
import com.eling.elcms.core.dao.annotation.In;
import com.eling.elcms.core.dao.hibernate.OrderCriteriaEnhancer;
import com.eling.elcms.core.model.BaseModel;
import com.eling.elcms.privilege.service.impl.CommonPrivilegeCriteriaEnhancer;
import org.hibernate.search.annotations.DocumentId;
import org.hibernate.search.annotations.Field;
import org.hibernate.search.annotations.Indexed;
import org.hibernate.search.annotations.IndexedEmbedded;

import javax.persistence.*;
import java.util.Set;

/** 产品规则
 * 
 * @author liuying
 * 
 * 模型评审：新增模型，wulina 2016-09-07
 *
 */
@Entity
@Table(name = "travel_productrule")
@Indexed
@CriteriaEnhancers(criteriaEnhancers = {
		@CriteriaEnhancer(impl = OrderCriteriaEnhancer.class),
		@CriteriaEnhancer(impl = CommonPrivilegeCriteriaEnhancer.class, parameter = "organization:product.organization") })
public class ProductRule extends BaseModel {

	private static final long serialVersionUID = -3823374199719508654L;

	@Id
	@DocumentId
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	private Long pkProductRule;
	
	/** 产品 */
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "pkProduct")
	@IndexedEmbedded(depth = 1)
	@In
	private Product product;
	
	/** 服务范围 */
	@ManyToMany
	@JoinTable(name = "travel_product_community",
	joinColumns = {@JoinColumn(name = "pkProductRule")},
	inverseJoinColumns = {@JoinColumn(name = "pkProductCommunity")})
	@IndexedEmbedded(depth = 1)
	private Set<CommunityData> communityDatas;
	
	/** 入住适用人数*/
	@Column
	@Field
	private Integer checkInNum;
	
	/** 旅居适用人数*/
	@Column
	@Field
	private Integer travelNum;
	
	/** 适用房间数*/
	@Column
	@Field
	private Integer roomNum;
	
	/** 保险项目 */
	@Column
	@Field
	private String insurance;
	
	/** 可退还 */
	@Column
	@Field
	private Boolean isReturn;
	
	/** 可转让 */
	@Column
	@Field
	private Boolean transfer;
	
	/** 可继承 */
	@Column
	@Field
	private Boolean isExtends;
	
	/** 可借出 */
	@Column
	@Field
	private Boolean lendable;
	
	/** 可续签 */
	@Column
	@Field
	private Boolean renewable;
	
	/** 是否促销 */
	@Column
	@Field
	private Boolean sales;
	
	/** 描述 */
	@Column(length = 1023)
	@Field
	private String description;

	@Version
	private Integer version;

	public Long getPkProductRule() {
		return pkProductRule;
	}

	public void setPkProductRule(Long pkProductRule) {
		this.pkProductRule = pkProductRule;
	}

	public Product getProduct() {
		return product;
	}

	public void setProduct(Product product) {
		this.product = product;
	}

	public Set<CommunityData> getCommunityDatas() {
		return communityDatas;
	}

	public void setCommunityDatas(Set<CommunityData> communityDatas) {
		this.communityDatas = communityDatas;
	}

	public Integer getCheckInNum() {
		return checkInNum;
	}

	public void setCheckInNum(Integer checkInNum) {
		this.checkInNum = checkInNum;
	}

	public Integer getTravelNum() {
		return travelNum;
	}

	public void setTravelNum(Integer travelNum) {
		this.travelNum = travelNum;
	}

	public String getInsurance() {
		return insurance;
	}

	public void setInsurance(String insurance) {
		this.insurance = insurance;
	}

	public Boolean getIsReturn() {
		return isReturn;
	}

	public void setIsReturn(Boolean isReturn) {
		this.isReturn = isReturn;
	}

	public Boolean getTransfer() {
		return transfer;
	}

	public void setTransfer(Boolean transfer) {
		this.transfer = transfer;
	}

	public Boolean getIsExtends() {
		return isExtends;
	}

	public void setIsExtends(Boolean isExtends) {
		this.isExtends = isExtends;
	}

	public Boolean getLendable() {
		return lendable;
	}

	public void setLendable(Boolean lendable) {
		this.lendable = lendable;
	}

	public Boolean getRenewable() {
		return renewable;
	}

	public void setRenewable(Boolean renewable) {
		this.renewable = renewable;
	}

	public Boolean getSales() {
		return sales;
	}

	public void setSales(Boolean sales) {
		this.sales = sales;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public Integer getVersion() {
		return version;
	}

	public void setVersion(Integer version) {
		this.version = version;
	}

	public Integer getRoomNum() {
		return roomNum;
	}

	public void setRoomNum(Integer roomNum) {
		this.roomNum = roomNum;
	}
}
